package com.forevershine.action;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.cohesion.bootstrap.common.MemoryCacheImpl;
import com.forevershine.business.context.ContextBuilder;
import com.forevershine.business.model.ActionNotes;
import com.forevershine.business.model.BodyFabric;
import com.forevershine.business.model.StyleDetail;
import com.forevershine.business.model.IndentBreakdown;
import com.forevershine.business.model.Trim;
import com.forevershine.business.service.impl.ActionNotesServiceImpl;
import com.forevershine.business.service.impl.BodyFabricServiceImpl;
import com.forevershine.business.service.impl.IndentBreakdownServiceImpl;
import com.forevershine.business.service.impl.TrimServiceImpl;
import com.forevershine.common.BusinessConstants;
import com.opensymphony.xwork2.ActionContext;

public class BriefAction extends BaseAction {

	private static Log log = LogFactory.getLog(TopMenuAction.class);

	private StyleDetail briefVo;

	private BodyFabric bodyFabric;
	
	private Trim trim;
	
	private ActionNotes actionNotes;
	
	private IndentBreakdown indentBreakdown;

	private MemoryCacheImpl cache =MemoryCacheImpl.INSTANCE;

	public StyleDetail getModel() {
		return briefVo;
	}

	public void setModel(StyleDetail model) {
		this.briefVo = model;
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	@Override
	protected String service() {
		// TODO Auto-generated method stub
		Object taskId = ActionContext.getContext().getParameters()
				.get("taskId");
		if (taskId == null) {
			log.debug("taskId is null.");
		} else {
			// TODO authenticate whether users are able to retrieve this order or not.
			int taskIdInt = Integer.valueOf(taskId.toString());
			
			this.bodyFabric = ContextBuilder.getContext().getInstance(
					BodyFabricServiceImpl.class).loadBodyFabric(taskIdInt);
			this.actionNotes = ContextBuilder.getContext().getInstance(
					ActionNotesServiceImpl.class).loadActionNotes(taskIdInt);
			this.trim = ContextBuilder.getContext().getInstance(
					TrimServiceImpl.class).loadTrim(taskIdInt);
			this.indentBreakdown =  ContextBuilder.getContext().getInstance(
					IndentBreakdownServiceImpl.class).loadIndentBreakdown(taskIdInt);
			
		}
		return SUCCESS;
	}
	
	public List<String> getBrand(){
		return (List)cache.get(BusinessConstants.BRAND);		
	}
	
	
	public List<String> getCustomer(){
		return (List)cache.get(BusinessConstants.CUSTOMER);		
	}
	
	public List<String> getGarmentType()
	{
		return (List)cache.get(BusinessConstants.GARMENT_TYPE);	
	}

}
